//
//  JSTImageView.h
//  KYKJPackDemo
//
//  Created by 01 on 17/5/11.
//  Copyright © 2017年 ???. All rights reserved.
//

#import <UIKit/UIKit.h>

@protocol EGOImageViewDelegate;
@protocol SNImageLoadOperation;

/**
 *  配置的初始化方法
 */
SN_EXTERN void SNImageCacheConfig(void);

/**
 *  清空图片缓存
 *
 *  @param completion 清除完成的回调
 */
SN_EXTERN void SNImageCacheClearWithCompletion(dispatch_block_t completion);

/**
 *  预加载图片
 *
 *  @param urls 图片url数组
 */
SN_EXTERN void SNImageCachePreloadImages(NSArray *urls);

/**
 *  从网络或缓存中获取图片
 *
 *  @param url             图片url
 *  @param completion 获取的图片
 */
SN_EXTERN id<SNImageLoadOperation> SNImageLoadImage(NSURL *url, void(^completion)(UIImage *image));

/**
 *  清空内存缓存
 */
SN_EXTERN void SNImageCacheClearMemory(void);

@interface JSTImageView : UIImageView
{
    NSURL       *_imageURL;
    UIImage     *_placeholder;
    UIImage     *_adjustedPlaceholder;
}

/** imageURL */
@property (nonatomic, strong) NSURL *imageURL;
/** placeholder */
@property (nonatomic, strong) UIImage *placeholderImage;
/** ImageOptions,  */
@property (nonatomic, assign) NSUInteger cacheOptions;
/** Loading框 */
@property (nonatomic, strong) UIActivityIndicatorView *indicatorView;
/** 是否展示加载中 */
@property (nonatomic, assign) BOOL shouldShowIndicator;
/** 设置为YES时，cache由NSURLCache管理*/
@property (nonatomic, assign) BOOL refreshCached;
/** 点击事件 */
@property (nonatomic, copy) void (^touchEndBlock)(JSTImageView *imgView);

@property(nonatomic, weak) id<EGOImageViewDelegate> delegate;

@property (nonatomic, strong)     UIImageView     *topLineImage;
@property (nonatomic, strong)     UIImageView     *rightLineImage;
@property (nonatomic, strong)     UIImageView     *bottomLineImage;
@property (nonatomic, strong)     UIImageView     *leftLineImage;

- (void)addFullLine;
@end

@protocol EGOImageViewDelegate <NSObject>
@optional
- (void)imageExViewDidOk:(JSTImageView *)imageViewEx;
- (void)imageViewLoadedImage:(JSTImageView*)imageView;
- (void)imageViewFailedToLoadImage:(JSTImageView*)imageView error:(NSError*)error;

@end
